public class code {
    public static void main(String[] args) {
      int num = 2;
      Hanoi(3,'A','B','C');
        System.out.println();
        Hanoi(4,'A','B','C');
    }
    public static void print(char A , char B) {
        System.out.print(A + "->" + B + " ");
    }
    public static void Hanoi (int num , char A,char B,char C){
        if(num == 1){
            print(A,C);
        }else{
            Hanoi(num - 1,A,C,B);
            print(A,C);
            Hanoi(num - 1,B,A,C);

        }
    }
}
